package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.miaodong.entity.AppSetup;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;

/**
 * 后台设置
 */
@Repository
public class AppSetupDao extends BaseDao<AppSetup> {

    /**
     *
     * 详情
     */
    public AppSetup get() {
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from app_setup limit 1");
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, AppSetup.class);
    }

    /**
     * 添加/修改
     */
    public void save(AppSetup haoYou) {
        if (haoYou.getId() != null && haoYou.getId() > 0) {
            this.update(haoYou);
        } else {
            haoYou.setId(this.add(haoYou));
        }
    }

    /**
     * 删除
     */
    public void del(Integer id) {
        if (id <= 0) {
            return;
        }
        String sql = "delete  from app_setup where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }
}
